export const shareMixins = {
	// data() {
	// 	return {
	// 		shareData: {
	// 			title: '',
	// 			path: '',
	// 			imageUrl: '',
	// 			content: '',
	// 			desc: ''
	// 		}
	// 	}
	// },
	
	getBase64(url) {
		return new Promise((resolve, reject) => {
			var Img = new Image()
			var dataURL = ''
			Img.setAttribute('crossOrigin', 'Anonymous')
			Img.src = url + '?v=' + Math.random()
			Img.onload = function() {
				// 要先确保图片完整获取到，这是个异步事件
				var canvas = document.createElement('canvas') // 创建canvas元素
				var width = Img.width // 确保canvas的尺寸和图片一样
				var height = Img.height
				canvas.width = width
				canvas.height = height
				canvas.getContext('2d').drawImage(Img, 0, 0, width, height) // 将图片绘制到canvas中
				dataURL = canvas.toDataURL('image/jpeg') // 转换图片为dataURL
				resolve(dataURL)
			}
		})
	},

	//#ifdef MP-WEIXIN
	onShareAppMessage() {
		return {
			title: this.shareData.name,
			// path: this.shareData.path,
			imageUrl: this.shareData.imgUrl,
			// content: this.shareData.content,
			// desc: this.shareData.content,
			success: res => {
				console.info(res)
			}
		}
	},
	//#endif

	onLoad(option) {
		
	}
	

}
